home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / dev / graphics.h < prev    next >
C/C++ Source or Header  |  1991-06-26  |  10KB  |  349 lines

  1. /*
  2.  * graphics.h --
  3.  *
  4.  *    This file defines the device-dependent IOControl calls and related
  5.  *    structures for graphics devices, which are used on DS3100's to
  6.  *    interact with the display and mouse.
  7.  *
  8.  * Copyright 1989 Regents of the University of California
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any purpose and without
  11.  * fee is hereby granted, provided that the above copyright
  12.  * notice appear in all copies.  The University of California
  13.  * makes no representations about the suitability of this
  14.  * software for any purpose.  It is provided "as is" without
  15.  * express or implied warranty.
  16.  *
  17.  * $Header: /sprite/src/lib/include/dev/RCS/graphics.h,v 1.5 91/06/25 22:16:02 mottsmth Exp $ SPRITE (Berkeley)
  18.  */
  19.  
  20. #ifndef _GRAPHICS
  21. #define _GRAPHICS
  22.  
  23. /*
  24.  * Constants:  these are the IOControl operations defined for tty's.
  25.  * The UNIX IOControl names are defined in ioctl.h.
  26.  */
  27.  
  28. #define IOC_GRAPHICS (7 << 16)
  29.  
  30. #define IOC_GRAPHICS_GET_INFO        (IOC_GRAPHICS | 0x1)
  31. #define IOC_GRAPHICS_MOUSE_POS        (IOC_GRAPHICS | 0x2)
  32. #define IOC_GRAPHICS_CURSOR_COLOR    (IOC_GRAPHICS | 0x3)
  33. #define IOC_GRAPHICS_INIT_SCREEN    (IOC_GRAPHICS | 0x4)
  34. #define IOC_GRAPHICS_KBD_CMD        (IOC_GRAPHICS | 0x5)
  35. #define IOC_GRAPHICS_GET_INFO_ADDR    (IOC_GRAPHICS | 0x6)
  36. #define IOC_GRAPHICS_CURSOR_BIT_MAP    (IOC_GRAPHICS | 0x7)
  37. #define IOC_GRAPHICS_KERN_LOOP        (IOC_GRAPHICS | 0x8)
  38. #define IOC_GRAPHICS_KERN_UNLOOP    (IOC_GRAPHICS | 0x9)
  39. #define IOC_GRAPHICS_VIDEO_ON        (IOC_GRAPHICS | 0xa)
  40. #define IOC_GRAPHICS_VIDEO_OFF        (IOC_GRAPHICS | 0xb)
  41. #define IOC_GRAPHICS_COLOR_MAP        (IOC_GRAPHICS | 0xc)
  42. #define IOC_GRAPHICS_IS_COLOR        (IOC_GRAPHICS | 0xd)
  43.  
  44. /*
  45.  * Cursor command register bits.
  46.  *
  47.  *     DEV_CURSOR_ENPA    Enable cursor plane A.
  48.  *     DEV_CURSOR_FOPA    Force cursor plane A to output 1.
  49.  *     DEV_CURSOR_ENPB    Enable cursor plane B.
  50.  *     DEV_CURSOR_FOPB    Force cursor plane B to output 1.
  51.  *     DEV_CURSOR_XHAIR    
  52.  *     DEV_CURSOR_XHCLP    Clip crosshair inside region.    
  53.  *     DEV_CURSOR_XHCL1    Select crosshair clipping region.
  54.  *     DEV_CURSOR_XHWID    Crosshair cursor line width.
  55.  *     DEV_CURSOR_ENRG1    Enable region detector 1.
  56.  *     DEV_CURSOR_FORG1    Force region detector 1 to output 1.
  57.  *     DEV_CURSOR_ENRG2    Enable region detector 2.
  58.  *     DEV_CURSOR_FORG2    Force region detector 2 to output 1.
  59.  *     DEV_CURSOR_LODSA    Load/display sprite array.
  60.  *     DEV_CURSOR_VBHI    Vertical blank polarity.
  61.  *     DEV_CURSOR_HSHI    Horizontal sync polarity.
  62.  *     DEV_CURSOR_TEST    Diagnostic test.
  63.  */
  64. #define DEV_CURSOR_ENPA        0x0001
  65. #define DEV_CURSOR_FOPA        0x0002
  66. #define DEV_CURSOR_ENPB        0x0004
  67. #define DEV_CURSOR_FOPB        0x0008
  68. #define DEV_CURSOR_XHAIR    0x0010
  69. #define DEV_CURSOR_XHCLP    0x0020
  70. #define DEV_CURSOR_XHCL1    0x0040
  71. #define DEV_CURSOR_XHWID    0x0080
  72. #define DEV_CURSOR_ENRG1    0x0100
  73. #define DEV_CURSOR_FORG1    0x0200
  74. #define DEV_CURSOR_ENRG2    0x0400
  75. #define DEV_CURSOR_FORG2    0x0800
  76. #define DEV_CURSOR_LODSA    0x1000
  77. #define DEV_CURSOR_VBHI        0x2000
  78. #define DEV_CURSOR_HSHI        0x4000
  79. #define DEV_CURSOR_TEST        0x8000
  80.  
  81. /*
  82.  * The cursor register.
  83.  */
  84. typedef volatile struct {
  85.     unsigned short    cmdReg;    /* Command register. */
  86.     unsigned short    pad1;
  87.     unsigned short    xPos;    /* X position. */
  88.     unsigned short    pad2;
  89.     unsigned short    yPos;    /* Y position. */
  90.     unsigned short    pad3;
  91.     unsigned short    xMin1;
  92.     unsigned short    pad4;
  93.     unsigned short    xMax1;
  94.     unsigned short    pad5;
  95.     unsigned short    yMin1;
  96.     unsigned short    pad6;
  97.     unsigned short    yMax1;
  98.     unsigned short    pad7;
  99.     unsigned short    unused7;
  100.     unsigned short    padUnused7;
  101.     unsigned short    unused8;
  102.     unsigned short    padUnused8;
  103.     unsigned short    unused9;
  104.     unsigned short    padUnused9;
  105.     unsigned short    unusedA;
  106.     unsigned short    padUnusedA;
  107.     unsigned short    xMin2;
  108.     unsigned short    pad8;
  109.     unsigned short    xMax2;
  110.     unsigned short    pad9;
  111.     unsigned short    yMin2;
  112.     unsigned short    padA;
  113.     unsigned short    yMax2;
  114.     unsigned short    padB;
  115.     unsigned short    memory;
  116.     unsigned short    padC;
  117. } DevPCCRegs;
  118.  
  119. /*
  120.  * The VDAC register.
  121.  */
  122. typedef volatile struct {
  123.     unsigned char   mapWA;
  124.     unsigned char   pad0;
  125.     unsigned short  pad1;
  126.  
  127.     unsigned char   map;
  128.     unsigned char   pad2;
  129.     unsigned short  pad3;
  130.  
  131.     unsigned char   mask;
  132.     unsigned char   pad4;
  133.     unsigned short  pad5;
  134.  
  135.     unsigned char   mapRA;
  136.     unsigned char   pad6;
  137.     unsigned short  pad7;
  138.  
  139.     unsigned char   overWA;
  140.     unsigned char   pad8;
  141.     unsigned short  pad9;
  142.  
  143.     unsigned char   over;
  144.     unsigned char   pad10;
  145.     unsigned short  pad11;
  146.  
  147.     unsigned char   reserved;
  148.     unsigned char   pad12;
  149.     unsigned short  pad13;
  150.  
  151.     unsigned char   overRA;
  152.     unsigned char   pad14;
  153.     unsigned short  pad15;
  154. } DevVDACRegs;
  155.  
  156. /*
  157.  *  Events.
  158.  */
  159. typedef struct {
  160.         short            x;        /* x position */
  161.         short             y;        /* y position */
  162.         unsigned int    time;        /* 1 millisecond units */
  163.         unsigned char   type;        /* button up/down/raw or motion */
  164.         unsigned char   key;        /* the key (button only) */
  165.         unsigned char   index;        /* which instance of device */
  166.         unsigned char   device;        /* which device */
  167. } DevEvent;
  168.  
  169. /*
  170.  * type field
  171.  */
  172. #define DEV_BUTTON_UP_TYPE          0
  173. #define DEV_BUTTON_DOWN_TYPE        1
  174. #define DEV_BUTTON_RAW_TYPE         2
  175. #define DEV_MOTION_TYPE             3
  176. /*
  177.  * Key field.
  178.  */
  179. #define DEV_EVENT_LEFT_BUTTON    0x01
  180. #define DEV_EVENT_MIDDLE_BUTTON    0x02
  181. #define DEV_EVENT_RIGHT_BUTTON    0x03
  182. /*
  183.  * device field
  184.  */
  185. #define DEV_NULL_DEVICE          0    /* NULL event (for QD_GETEVENT ret) */
  186. #define DEV_MOUSE_DEVICE    1        /* mouse */
  187. #define DEV_KEYBOARD_DEVICE    2        /* main keyboard */
  188. #define DEV_TABLET_DEVICE    3        /* graphics tablet */
  189. #define DEV_AUX_DEVICE          4        /* auxiliary */
  190. #define DEV_CONSOLE_DEVICE    5        /* console */
  191. #define DEV_KNOB_DEVICE          8
  192. #define DEV_JOYSTICK_DEVICE    9
  193.  
  194. #define DEV_MAXEVQ    64    /* must be power of 2 */
  195. #define DEV_EVROUND(x)    ((x) & (DEV_MAXEVQ - 1))
  196. #define DEV_TABLET_RES    2
  197.  
  198. typedef struct {
  199.     unsigned int    time;
  200.     short        x, y;
  201. } DevTimeCoord;
  202.  
  203. /*
  204.  * The event queue. This structure is normally included in the info
  205.  * returned by the device driver.
  206.  */
  207. typedef struct {
  208.     DevEvent    *events;
  209.     unsigned int     eSize;
  210.         unsigned int    eHead;
  211.         unsigned int    eTail;
  212.     unsigned long    timestampMS;
  213.     DevTimeCoord    *tcs;    /* history of pointer motions */
  214.     unsigned int    tcSize;
  215.     unsigned int    tcNext;    /* simple ring buffer, old events are tossed */
  216. } DevEventQueue;
  217.  
  218. /* 
  219.  * mouse cursor position
  220.  */
  221. typedef struct {
  222.         short x;
  223.         short y;
  224. } DevCursor;
  225.  
  226. /* 
  227.  * mouse motion rectangle
  228.  */
  229. typedef struct {
  230.         short bottom;
  231.         short right;
  232.         short left;
  233.         short top;
  234. } DevBox;
  235.  
  236. /*
  237.  * Structures used by iocontrols.
  238.  */
  239. typedef struct {
  240.     char nbytes;        /* Number of bytes in parameter */
  241.     unsigned char cmd;    /* Command to be sent, peripheral bit will */
  242.                 /* be forced by driver */
  243.     unsigned char par[2];    /* Bytes of parameters to be sent */
  244. } DevKpCmd;
  245.  
  246. /*
  247.  * Information about the screen.
  248.  */
  249. typedef struct {
  250.     DevEventQueue eventQueue;    /* event & motion queues    */
  251.     short    mswitches;        /* current value of mouse buttons */
  252.     DevCursor tablet;        /* current tablet position    */
  253.     short    tswitches;        /* current tablet buttons NI!    */
  254.     DevCursor cursor;        /* current cursor position    */
  255.     short    row;            /* screen row            */
  256.     short    col;            /* screen col            */
  257.     short    maxRow;            /* max character row        */
  258.     short    maxCol;            /* max character col        */
  259.     short    maxX;            /* max x position        */
  260.     short    maxY;            /* max y position        */
  261.     short    maxCurX;        /* max cursor x position     */
  262.     short    maxCurY;        /* max cursor y position    */
  263.     int    version;        /* version of driver        */
  264.     char    *bitmap;        /* bit map position        */
  265.         short   *scanmap;               /* scanline map position        */
  266.     short    *cursorBits;        /* cursor bit position        */
  267.     short    *vaddr;            /* virtual address               */
  268.     char    *planeMask;        /* plane mask virtual location  */
  269.     DevCursor mouse;        /* atomic read/write        */
  270.     DevBox    mbox;            /* atomic read/write        */
  271.     short    mthreshold;        /* mouse motion parameter    */
  272.     short    mscale;            /* mouse scale factor (if 
  273.                        negative, then do square).    */
  274.     short    minCurX;        /* min cursor x position    */
  275.     short    minCurY;        /* min cursor y position    */
  276. } DevScreenInfo;
  277.  
  278. /*
  279.  *  This screen info is an extended version used by the graphics accelerator
  280.  *  cards in the ds5000.
  281.  */
  282.  
  283. #define DEV_CUR_SIZE (64 * 64 / 4)
  284.  
  285. typedef struct {
  286.     DevEventQueue eventQueue;    /* event & motion queues    */
  287.     short    mswitches;        /* current value of mouse buttons */
  288.     DevCursor tablet;        /* current tablet position    */
  289.     short    tswitches;        /* current tablet buttons NI!    */
  290.     DevCursor cursor;        /* current cursor position    */
  291.     short    row;            /* screen row            */
  292.     short    col;            /* screen col            */
  293.     short    maxRow;            /* max character row        */
  294.     short    maxCol;            /* max character col        */
  295.     short    maxX;            /* max x position        */
  296.     short    maxY;            /* max y position        */
  297.     short    maxCurX;        /* max cursor x position     */
  298.     short    maxCurY;        /* max cursor y position    */
  299.     int    version;        /* version of driver        */
  300.     int    flags;            /* sync flags            */
  301.     char    *memPtr;        /* memory on graphics board    */
  302.     char    *bufPtr;        /* start of ring buffer        */
  303.     char    *bufPhysPtr;        /* physical address of bufPtr    */
  304.     int    bufSize;        /* size of ring buffer        */
  305.     DevCursor mouse;        /* atomic read/write        */
  306.     DevBox    mbox;            /* atomic read/write        */
  307.     short    mthreshold;        /* mouse motion parameter    */
  308.     short    mscale;            /* mouse scale factor (if 
  309.                        negative, then do square).    */
  310.     short    minCurX;        /* min cursor x position    */
  311.     short    minCurY;        /* min cursor y position    */
  312.     char    *fooPtr;        
  313.     char    stampWidth;
  314.     char    stampHeight;
  315.     char    nPlanes;        /* primary buffer        */
  316.     char    accPresent;        /* geometry accelerator present    */
  317.     char    dPlanes;        /* double buffer        */
  318.     char    zplanes;        /* Z buffer            */
  319.     char    zzplanes;        /* extra buffer            */
  320.     unsigned char cursBits[DEV_CUR_SIZE];
  321.     int    cursFG;
  322.     int    cursBG;            
  323.     unsigned short cmapIndex;    /* start CMAP update here    */
  324.     unsigned short cmapCount;    /* update this # of CMAP entries*/
  325.     int    colormap[256];
  326.     int    *sticPollReg;        /* STIC polling register    */
  327.     int    *sticReg;        /* STIC control registers    */
  328.     int    ptptPhys;        /* phys addr: ptpt        */
  329.     int    ptptSize;        /* # entries in ptpt        */
  330.     int    *ptptPagein;        /* request server pagein    */
  331. } DevScreenInfoExt;
  332.  
  333. typedef struct {
  334.     short        map;
  335.     unsigned short    index;
  336.     struct {
  337.         unsigned short red;
  338.         unsigned short green;
  339.         unsigned short blue;
  340.     } entry;
  341. } DevColorMap;
  342.  
  343. /*
  344.  * The unit number of /dev/mouse.
  345.  */
  346. #define DEV_MOUSE_UNIT    1
  347.  
  348. #endif _GRAPHICS
  349.